package liuwanghui.mapper;

import liuwanghui.dto.request.*;
import liuwanghui.dto.response.HotProductDTO;
import liuwanghui.dto.response.LowStockProductDTO;
import liuwanghui.pojo.Inventory;
import liuwanghui.pojo.Order;
import liuwanghui.pojo.Product;
import liuwanghui.vo.InventoryVO;
import liuwanghui.vo.OrderVO;
import liuwanghui.vo.ProductVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface DealerMapper {
    // 统计相关
    Integer getTotalProducts();
    Integer getPendingOrders();
    BigDecimal getMonthSales();
    List<HotProductDTO> getHotProducts();
    BigDecimal getSalesByDateRange(@Param("startTime") LocalDateTime startTime, 
                                 @Param("endTime") LocalDateTime endTime,
                                 @Param("category") String category);
    List<Map<String, Object>> getCategoryStats(@Param("startTime") LocalDateTime startTime,
                                             @Param("endTime") LocalDateTime endTime);
    List<Map<String, Object>> getDailyStats(@Param("startTime") LocalDateTime startTime,
                                          @Param("endTime") LocalDateTime endTime);
    
    // 商品相关
    List<ProductVO> findProductsBySearch(ProductQueryDTO params);
    Product findProductById(@Param("id") Long id);
    void updateProductStatus(@Param("id") Long id, @Param("status") String status);
    void insertProductStatusLog(ProductStatusLogDTO log);
    
    // 库存相关
    List<LowStockProductDTO> getLowStockProducts(@Param("threshold") Integer threshold,
                                                @Param("category") String category,
                                                @Param("warehouse") String warehouse);
    Inventory findInventoryById(@Param("id") Long id);
    void updateInventoryStock(Inventory inventory);
    void insertStockLog(StockLogDTO log);
    List<InventoryVO> getInventoryProducts(@Param("category") String category,
                                         @Param("warehouse") String warehouse,
                                         @Param("status") String status);
    void updateInventoryMinStock(@Param("id") Long id, @Param("minStock") Integer minStock);
    
    // 订单相关
    Order findOrderById(@Param("id") Long id);
    List<OrderVO> getRecentOrders(@Param("limit") int limit);
    List<OrderVO> getCompletedOrders(@Param("limit") int limit);
} 